<?php foreach($menu as $k=>$menu) {?>

	<li class="menus_parent">
	   <a href="#">
		   <i class="<?php echo $menu[0]->parent_icon; ?>"></i> 
		   <span class="title"><?php echo ucwords(strtolower($k)); ?></span>
			<span class="arrow "></span>
			<span class="select"></span>
	   </a>
	   
		<ul class="sub-menu">
			<?php foreach($menu as $childmenu) { ?>
			<li class="menu" data-url="<?php echo $childmenu->menus_url; ?>" data-param="<?php echo $childmenu->menus_param; ?>" >
				<a href="#" >
				<?php echo  ucwords(strtolower($childmenu->menus_label)); ?></a>
			</li>
			<?php } ?>
		</ul>
		
	</li>
	

<?php } ?>

<script>
	$(function(){
		
		/* declarisasi */
		// mainmenu = $(".mainmenu li a");
		menu = $(".menu");
		main_content = $(".main");
		// loading = $("#loading");
		
		/* function */
		function urlparamToObject(urlparam){
			return JSON.parse('{"' + decodeURI(urlparam).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}');
		}
		
		/* event */
		menu.click(function(){
			data = $(this).data();
			menu.removeClass("active");
			$(this).addClass("active");
			$(".menus_parent").removeClass("active");
			$(".menus_parent").find(".select").removeClass("selected");
			$(this).parent().parent().addClass("active");
			$(this).parent().parent().find(".select").addClass("selected");
			
			$(".page-title").html($(this).find("a").text()+
			"<small>"+$(this).find("a").text()+"</small>");
			$(".page-breadcrumb").html('<li> <i class="icon-home"></i> <a href="index.html">Home</a> <i class="icon-angle-right"></i> </li>'+
			'<li> <a href="#">'+$(this).parent().parent().find(".title").text()+'</a><i class="icon-angle-right"></i>'+
            '</li><li><a href="#">'+$(this).find("a").text()+'</a></li>');
			
			// loading.show();
			if (data.url != ""){
				var param = null;
				var urlparam = data.param ;
				if (urlparam != null && urlparam != "" )
					param = urlparamToObject(urlparam);
				// main_content.load(data.url,param,function(){ loading.hide("slow"); });
					main_content.load(data.url,param);
				
			}
		});
		<?php if (@$_GET["url"] == "" && @$_GET["task"] == "") { ?>
			$(".menus_parent .menu").first().click();
		<?php }else{ ?>
			main_content.load( '<?php echo @$_GET["url"]; ?>' , {task :  '<?php echo @$_GET["task"]; ?>'});
		<?php } ?>
		// loading.hide();
		// 

	});
</script>